﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EKETEAM.FrameWork;
using EKETEAM.Data;

namespace EKECMS.Controls
{
    public partial class mCopyRight : System.Web.UI.UserControl
    {
        private eSiteInfo _SiteInfo;
        public eSiteInfo SiteInfo
        {
            get { return _SiteInfo; }
            set { _SiteInfo = value; }
        }
        private string tools;
        public string Tools
        {
            get
            {
                tools = (string)HttpRuntime.Cache.Get("mTools");
                if (tools == null)
                {
                    tools = "";
                    int ct = 1;
                    if (SiteInfo.Site["ContentTel"].ToString().Length > 0) ct++;
                    string sql = "select top 1 ColumnID,MC from eWeb_Columns where Type=1 and WebCode='" + eBase.getWebCode() + "' and mc like '%联系%' and delTag=0 and show=1";
                    DataRowCollection drcontent = eBase.DataBase.getDataTable(sql).Rows;
                    if (drcontent.Count > 0) ct++;

                    sql = "select top 1 ColumnID,MC from eWeb_Columns where Type=7 and WebCode='" + eBase.getWebCode() + "' and delTag=0 and show=1";
                    DataRowCollection drmsg = eBase.DataBase.getDataTable(sql).Rows;
                    if (drmsg.Count > 0) ct++;
                    int width = 100 / ct;

                    tools = "<li style=\"width:" + width.ToString() + "%;\"><a  href=\"Default.aspx\" ><img src=\"../Plugins/mred/images/home.png\"><p>首页</p></a></li>\r\n";
                    if (SiteInfo.Site["ContentTel"].ToString().Length > 0)
                    {
                        tools += "<li style=\"width:" + width.ToString() + "%;\"><a  href=\"tel:" + SiteInfo.Site["ContentTel"].ToString().Replace("-", "") + "\"><img src=\"../Plugins/mred/images/tel.png\"><p>一键拨号</p></a></li>\r\n";
                    }
                    if (drcontent.Count > 0)
                    {
                        tools += "<li style=\"width:" + width.ToString() + "%;\"><a href=\"Content.aspx?id=" + drcontent[0]["ColumnID"].ToString() + "\"><img src=\"../Plugins/mred/images/map.png\"><p>" + drcontent[0]["MC"].ToString() + "</p></a></li>\r\n";
                    }
                    if (drmsg.Count > 0)
                    {
                        tools += "<li style=\"width:" + width.ToString() + "%;\"><a  href=\"GuestBooks.aspx?id=" + drmsg[0]["ColumnID"].ToString() + "\"><img src=\"../Plugins/mred/images/guestbook.png\"><p>" + drmsg[0]["MC"].ToString() + "</p></a></li>\r\n";
                    }
                    HttpRuntime.Cache.Insert("mTools", tools);
                }
                return tools;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (SiteInfo == null) return;       
           
        }
    }
}